package com.party.business.controller;


import java.util.Arrays;
import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;

import com.party.common.annotation.DataSource;
import com.party.common.annotation.Log;
import com.party.common.core.controller.BaseController;
import com.party.common.core.domain.AjaxResult;
import com.party.common.core.page.TableDataInfo;
import com.party.common.enums.BusinessType;
import com.party.common.enums.DataSourceType;
import com.party.common.utils.poi.ExcelUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.party.business.domain.StrategicPolicie;
import com.party.business.service.IStrategicPolicieService;

/**
 * 战略政策Controller
 *
 * @author ruoyi
 * @date 2025-06-24
 */
@RestController
@RequestMapping("/business/policie" )
public class StrategicPolicieController extends BaseController {
    @Autowired
    private IStrategicPolicieService strategicPolicieService;

/**
 * 查询战略政策列表
 */
//@RequiresPermissions("business:policie:list")
@GetMapping("/list" )
@DataSource(value = DataSourceType.SLAVE)
    public TableDataInfo list(StrategicPolicie strategicPolicie) {
        startPage();
        List<StrategicPolicie> list = strategicPolicieService.selectStrategicPolicieList(strategicPolicie);
        return getDataTable(list);
    }

    /**
     * 导出战略政策列表
     */
    //@RequiresPermissions("business:policie:export")
    @Log(title = "战略政策" , businessType = BusinessType.EXPORT)
    @PostMapping("/export" )
    public void export(HttpServletResponse response, StrategicPolicie strategicPolicie) {
        List<StrategicPolicie> list = strategicPolicieService.selectStrategicPolicieList(strategicPolicie);
        ExcelUtil<StrategicPolicie> util = new ExcelUtil<StrategicPolicie>(StrategicPolicie. class);
        util.exportExcel(response, list, "战略政策数据" );
    }

    /**
     * 获取战略政策详细信息
     */
    //@RequiresPermissions("business:policie:query")
    @GetMapping(value = "/{id}" )
    @DataSource(value = DataSourceType.SLAVE)
    public AjaxResult getInfo(@PathVariable("id" ) Long id) {
        return AjaxResult.success(strategicPolicieService.selectStrategicPolicieById(id));
    }

    /**
     * 新增战略政策
     */
    //@RequiresPermissions("business:policie:add")
    @Log(title = "战略政策" , businessType = BusinessType.INSERT)
    @PostMapping
    @DataSource(value = DataSourceType.SLAVE)
    public AjaxResult add(@RequestBody StrategicPolicie strategicPolicie) {
        return toAjax(strategicPolicieService.insertStrategicPolicie(strategicPolicie));
    }

    /**
     * 修改战略政策
     */
    //@RequiresPermissions("business:policie:edit")
    @Log(title = "战略政策" , businessType = BusinessType.UPDATE)
    @PutMapping
    @DataSource(value = DataSourceType.SLAVE)
    public AjaxResult edit(@RequestBody StrategicPolicie strategicPolicie) {
        return toAjax(strategicPolicieService.updateStrategicPolicie(strategicPolicie));
    }

    /**
     * 删除战略政策
     */
    //@RequiresPermissions("business:policie:remove")
    @Log(title = "战略政策" , businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}" )
    @DataSource(value = DataSourceType.SLAVE)
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(strategicPolicieService.removeByIds(Arrays.asList(ids)));
    }
}
